package com.kmdd.xtds.ui

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.webkit.WebSettings
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
import com.kmdd.xtds.databinding.ActivityWebBinding
import com.gyf.immersionbar.ktx.immersionBar


class WebActivity : AppCompatActivity() {
    private lateinit var binding: ActivityWebBinding

    companion object {

        fun start(context: Context, url: String) {
            val intent = Intent(context, WebActivity::class.java)
            intent.putExtra("url", url)
            context.startActivity(intent)
        }

    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityWebBinding.inflate(layoutInflater)
        setContentView(binding.root)
        immersionBar {
            transparentBar()
            keyboardEnable(true)
            fitsSystemWindows(false)
            statusBarDarkFont(false)
        }

        val url = intent.getStringExtra("url") ?: ""
        Log.e("123",url)
        // 启用JavaScript
        // 启用JavaScript
        val webSettings: WebSettings = binding.webview.getSettings()
        webSettings.javaScriptEnabled = true

        // 设置WebViewClient以处理页面加载等事件

        // 设置WebViewClient以处理页面加载等事件
        binding.webview.webViewClient = WebViewClient()
        binding.webview.loadUrl(url)
        binding.frameLayoutBack.setOnClickListener {
            finish()
        }
    }
}